package main;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.io.*;

import Patterns.PatternGenerator;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) 
	{

		//--------------------------------------
		//Option 1: Specify parameters for random patterns. Random pattern will be generated
		//and solved with the Java regex and Janus automaton approach. An output file with the
		//test results is created. 
		
		//Specify test scenario
		int id = 24;
		int numberOfInstances = 100;
		int numberOfVariables = 5;
		int wordLength = 200;
		int variableDistance = 4;
		int alphabetSize = 2;
		ArrayList<int[]> minMaxoccurrenceVector = new ArrayList<int[]>();
		int temp[] = new int[2];
		
		for (int i = 0; i < numberOfVariables; i++)
		{
			temp[0] = 20;
			temp[1] = 30;
			minMaxoccurrenceVector.add(temp);
		}
		
		DateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy");
		Date date = new Date();
		String dateString = dateFormat.format(date);

		String testPrefix = "id" + id + "varNo" + numberOfVariables + "_minOcc"
				+ minMaxoccurrenceVector.get(0)[0] + "_maxOcc"
				+ minMaxoccurrenceVector.get(0)[1] + "_varDist"
				+ variableDistance;
		
		//Create directories and files
		String testDirectory = "U:\\TestResults\\FinalTests\\";
		File file = new File(testDirectory);
		boolean tempdir = file.mkdir();
		file = new File(testDirectory + dateString);
		tempdir = file.mkdir();
		file = new File(testDirectory + dateString + "\\"
				+ testPrefix);
		tempdir = file.mkdir();
		
		String inputFilename = file.getPath() + "\\" + testPrefix
				+ "_Test_Set.txt";
		String outputFilename = file.getPath() + "\\" + testPrefix
				+ "_Test_Results.txt";
		
		//create input instances
		PatternGenerator patternGenerator = new PatternGenerator(
				inputFilename);
		patternGenerator.printRandomPattern(numberOfInstances,
				minMaxoccurrenceVector, false, variableDistance,
				alphabetSize, wordLength);
		
		//Start test run
		TestrunManager testrunManager = new TestrunManager(inputFilename,
				outputFilename);
		testrunManager.run();
		//--------------------------------------
		
		
		//--------------------------------------
		//Option 2: Specify an input file with pattern membership instances. These instances will
		//be solved with the Java regex and Janus automaton approach. An output file with the
		//test results is created.
		
//		String inputFilename = "U:\\TestResults\\TEST\\instances.txt";
//		String outputFilename = "U:\\TestResults\\TEST\\results.txt";
//		
//		//Start test run
//		TestrunManager testrunManager = new TestrunManager(inputFilename,
//				outputFilename);
//		testrunManager.run();
		//--------------------------------------
			
	}
}
